<?php
/**
 * revocation list element class
 *
 * @final
 * @author raphael seebacher <raphasee@ee.ethz.ch>
 * @version 0.01
 */
final class revocation_list extends message_element_controller {
    public function get_tag() {
        return 'revocation_list';
    }

    protected function process_element() {
        if (array_key_exists('last_update', $this->content)) {
            $timestamp = $this->content['last_update'];
        }
        else {
            $timestamp = NULL;
        }

        $crl_certificates =
            user_certificate::get_certificate_revocation_list($timestamp);

        $crl = Array();
        foreach ($crl_certificates as $revoked_certificate) {
            $crl[] = Array(
              'expiry' => $revoked_certificate->get_timestamp('valid_to'),
              'revocation_time' => $revoked_certificate->get_timestamp('revoked'),
              'serial_number' => intval($revoked_certificate->get('serial_number'))
            );
        }

        return Array(
          'status' => 'ok',
          'crl' => $crl,
        );
    }
}
?>